<template>
  <div class="feedback-section">
    <div class="section-header">
      <h3>意见反馈</h3>
      <p class="description">您的每一条建议都是我们进步的动力</p>
    </div>
    <div class="feedback-content">
      <el-form 
        ref="formRef"
        :model="feedbackForm"
        :rules="rules"
        label-width="80px"
        class="feedback-form"
      >
        <el-form-item label="反馈类型" prop="type">
          <el-select v-model="feedbackForm.type" placeholder="请选择反馈类型">
            <el-option label="功能建议" value="feature" />
            <el-option label="问题反馈" value="bug" />
            <el-option label="其他" value="other" />
          </el-select>
        </el-form-item>
        
        <el-form-item label="反馈内容" prop="content">
          <el-input
            v-model="feedbackForm.content"
            type="textarea"
            :rows="4"
            placeholder="请详细描述您的建议或遇到的问题"
          />
        </el-form-item>

        <el-form-item label="联系方式" prop="contact">
          <el-input
            v-model="feedbackForm.contact"
            placeholder="请留下您的联系方式（选填）"
          />
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="submitFeedback">提交反馈</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script setup>
import { ref, reactive } from 'vue'
import { ElMessage } from 'element-plus'

const formRef = ref(null)

const feedbackForm = reactive({
  type: '',
  content: '',
  contact: ''
})

const rules = {
  type: [
    { required: true, message: '请选择反馈类型', trigger: 'change' }
  ],
  content: [
    { required: true, message: '请输入反馈内容', trigger: 'blur' },
    { min: 10, message: '反馈内容不能少于10个字符', trigger: 'blur' }
  ]
}

const submitFeedback = async () => {
  if (!formRef.value) return
  
  await formRef.value.validate((valid) => {
    if (valid) {
      // 这里可以添加实际的提交逻辑
      ElMessage.success('感谢您的反馈！')
      // 重置表单
      formRef.value.resetFields()
    }
  })
}
</script>

<style scoped>
.feedback-section {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}

.section-header {
  margin-bottom: 20px;
}

.section-header h3 {
  font-size: 18px;
  color: #333;
  margin: 0 0 8px 0;
}

.description {
  font-size: 14px;
  color: #666;
  margin: 0;
}

.feedback-content {
  padding: 20px 0;
}

.feedback-form {
  max-width: 600px;
  margin: 0 auto;
}

:deep(.el-form-item__label) {
  font-weight: 500;
}
</style> 